<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>推荐列表</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta http-equiv="Cache-Control" content="no-transform">
		<meta name="format-detection" content="telephone=no">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<link rel="stylesheet" href="style/css/basic.css" />
		<script type="text/javascript" src="style/plugin/mui/js/mui.min.js"></script>
		<script type="text/javascript" src="style/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="style/mockjs/dist/mock.js"></script>
		<script type="text/javascript" src="style/js/vue.min.js"></script>
		<script type="text/javascript" src="style/js/vue-resource.js"></script>
		<script type="text/javascript" src="style/js/basic.js"></script>
	</head>
	<style>
		.recommend_list li {
			line-height: 44px;
		}
		.cl{clear:both;}
	</style>

	<body>
		<div id="reclist">
			<!--header-->
			<div id="header">
				<h1>工单列表</h1>
				<span class="backicon"></span>
			</div>
			<!--content-->
			<div class="body" id="refreshContainer">
				<ul class="recommend_list list">
					<li v-for="(rec,index) in recommandList" v-if="recommandList!=''">
						<span class="fl">{{rec.name}}</span>
						<span class="fr gray">{{rec.phone}}</span>
						<div class="cl">
							<span class="fl"><i>工单号:</i><em>{{rec.form_no}}</em></span>
							<span class="fr">{{fTime(rec.create_time)}}</span>
						</div>
					</li>
				</ul>
			</div>
		</div>
		<script>
			
			new Vue({
				el:"#reclist",
				data:{
					recommandList:"",
					ticket:"",
				    sign:""
				},
				methods:{
					fTime:function(timestamp){
	                	if (typeof timestamp == "undefined") {
					        timestamp = Math.round(new Date().getTime() / 1000)
					    }
					    var n = parseInt(timestamp) * 1000
					    var date = new Date(n);
					    var Y = date.getFullYear() + '-';
					    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
					    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
					    var H=date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
					    var Min=date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
					    var S=date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
					    return (Y + M + D)
	                }
				},
				created:function(){
                    that.ticket=localStorage.getItem("tick")
                    that.sign=localStorage.getItem("sig")
				},
				mounted:function(){
					var p=1;
					var that=this; 
					mui.plusReady(function(){
						mui.init({
						  pullRefresh : {
						    container:"#refreshContainer",
						    down : {
						      style:'circle',
						      color:'#2BD009',
						      height:'50px',
						      range:'100px',
						      offset:'0px',  
						      contentdown:null,
						      auto: true,
						      callback :pullrefesh  	      
						    }
						  }  
						}); 
					})
					function pullrefesh(){
						that.$http.post(domain+"/agent/getRecommendFormList?t="+that.ticket+"&sign="+that.sign,{ 
						      	page:p++,
						      	page_size:7
						      },{emulateJSON:true}).then(
					            function (res) {
					                // 处理成功的结果
					                console.log(res.body)
					                if(res.body.code==1){
					                    if(res.body.data.length==0){
						                	mui.toast("没有更多了")
						                	return false;
						                  }
					                  that.recommandList=res.body.data.data;
					                  
					                }else{
					                	mui.toast("暂无商品")
					                }
					            },function (res) {
					            // 处理失败的结果
					            console.log(res) 
					            }
					        ).then(function(){
					        	mui('#refreshContainer').pullRefresh().endPulldownToRefresh();   
					        });
						
					}
				}
				
			})
		</script>
	</body>

</html>
